<?php
class CmsAjaxTabControl extends CmsBaseControl
{
    protected $selected;
    protected $parentId;
    protected $content = array();

    public function CmsAjaxTabControl()
    {
        parent::__construct();
        $this->parentId = RequestHandler::Get('parent_id');
        $this->config->AddSharedJs('CmsAjaxTabControl');
    }

    public function Render()
    {
        $tabs = CmsMenuModel::GetInstance()->GetChilds($this->parentId);
        $content = implode('', $this->content);
        $query =  parse_url($_SERVER['REQUEST_URI'], PHP_URL_QUERY);

        $this->Replace('query', $query);
        $this->Repeat('tab', $tabs);
        $this->Replace('content', $content);
        return parent::Render();
    }

    public function SetSelected($selected)
    {
        $this->selected = $selected;
    }

    public function AddContent($content)
    {
        $this->content[] = "<div>$content</div>";
    }
}
?>